package com.jwater.core.metrics;

import java.util.List;
import java.util.Map;
import java.util.Set;

import com.jwater.core.metrics.system.CpuMetric;
import com.jwater.core.metrics.system.DiskMetric;
import com.jwater.core.metrics.system.MemoryMetric;
import com.jwater.core.metrics.system.NetMetric;

/**
 * 依赖命令df netstat iostat ifstat
 * 
 * @author jnner
 *
 */
public class SystemMetric {
	private static Map<String, String> localHosts;

	public static List<Float> getAllCpuUsage() {
		return CpuMetric.getAllCpuUsage();
	}

	public static float getCpuUsage() {
		return CpuMetric.getCpuUsage();
	}

	public static Map<String, FileSystemSpace> getFileSystemSpace() {
		return DiskMetric.getFileSystemSpace();
	}

	public static Map<String, String> getDiskRate() {
		return DiskMetric.getDiskRate();
	}

	public static Map<String, Double> getSystemMemory() {
		return MemoryMetric.getSystemMemory();
	}

	public static Map<String, Set<Integer>> getUsedPort() {
		return NetMetric.getUsedPort();
	}

	public static Map<String, String> getHosts() {
		return NetMetric.getHosts();
	}

	public static Map<String, String> getNetRate() {
		return NetMetric.getNetRate();
	}

	public static boolean isLocalHost(String host) {
		if (localHosts == null) {
			localHosts = getHosts();
		}
		return localHosts.containsValue(host);
	}
}
